/*
 * @Date: 2021-11-28 15:24:20
 * @LastEditors: LeeKing
 * @LastEditTime: 2021-12-09 21:03:42
 * @FilePath: \demo\src\store\index.js
 */
import Vue from 'vue'
import Vuex from 'vuex'
import { getStorage, setStorage, removeStorage } from '@/utils/storage.js'
import FavoriteList from './modules/FavoriteList.js'
import RentList from './modules/RentList.js'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: getStorage('hzk-user'),
    city: getStorage('HZK-LOCALCITY') || '上海',
    cityId: getStorage('HZK-LOCALCITYID') || 'AREA|dbf46d32-7e76-1196'
  },
  mutations: {
    initUser (state, payload) {
      state.user = payload
      setStorage('hzk-user', payload)
    },
    removeUser (state) {
      state.user = null
      removeStorage('hzk-user')
    },
    // 获取点击的城市名称
    getCityName (state, payload) {
      state.city = payload
    },
    // 获取当前城市ID
    getLocalCityId (state, payload) {
      state.cityId = payload
    }

  },
  actions: {
  },
  modules: {
    FavoriteList,
    RentList
  }
})
